Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Scripting Additions Guide /
Chapter 2 - Scripting Addition Commands / Command Definitions
/


Choose File

The Choose File command displays a dialog box like the one in Figure 2-2 to allow the user to choose a file.

Figure 2-2 A Choose File dialog box

The Choose File command is one of two commands provided by the Choose File scripting addition.

SYNTAX
choose file [ with prompt promptString ] [ of type listOfTypes ]
PARAMETERS
promptString
The prompt to be displayed in the dialog box. The prompt can be up to 255 characters long, but the standard dialog box has room for only about 40 characters. If you omit the with prompt parameter, no prompt is displayed.
Class: String
Default Value: (no prompt)

listOfTypes
A list of the file types of the files to be displayed in the dialog box. Each string is a four-character code for the file type, such as "TEXT", "APPL", "PICT", or "PNTG". If you omit the of type parameter, all files are displayed.
Class: List of strings; each string is a four-letter code
Default Value: (all file types displayed)
RESULT
A reference of the form file "Disk:Folder1:Folder2:...:Filename" for the file specified by the user, if any.

EXAMPLE
choose file with prompt "Please choose a file:" of type ¨
   {"TEXT", "APPL"}
open result
NOTES
If the user clicks Cancel in the Choose File dialog box, AppleScript returns error number -128. If you want your script to continue after the user clicks Cancel, you must include an error handler. For information about Try statements
and error handlers, see Chapter 7, "Control Statements," of the AppleScript Language Guide.

ERRORS
Error
number
Error message
-108Out of memory.
-128User canceled.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
18 DEC 1996